import java.util.Arrays;

/**
 * @author LKQ
 * @date 2022/1/7 19:49
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(Arrays.toString(solution.countBits(5)));
    }
    public int[] countBits(int n) {
        int[] ans = new int[n+1];
        ans[0] = 0;
        for(int i = 1; i <= n; i++) {
            int count = 0;
            int temp = i;
            while (temp != 0) {
                temp &= (temp-1);
                count++;
            }
            ans[i] = count;
        }
        return ans;
    }
}
